﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ninject;

namespace LearnWeb
{
    public partial class NuGet : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //ninject使用(ioc控件)
            IKernel ninjKernel = new StandardKernel();
            ninjKernel.Bind<ITest>().To<Test>();//将实现类绑定给接口
            //var test = ninjKernel.Get<ITest>();
            //lb_show.Text = test.GetTest("jack");

            ninjKernel.Bind<IValue>().To<MValue>();

            var ivalue = ninjKernel.Get<IValue>();
            lb_show.Text = ivalue.returnValue();

        }
    }
    

    interface ITest
    {
        string GetTest(string testName);
    }

    class Test:ITest
    {

        public string GetTest(string testName)
        {
            return "The name =" +testName;
        }
    }

    interface IValue
    {
        string returnValue();
    }

    class MValue:IValue
    {
        private ITest test;

        public MValue(ITest tt)
        {
            test = tt;
        }

        public string returnValue()
        {
            return test.GetTest("ssssmmmm"); 
        }
    }
}